home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11521 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  48 lines

  1. Newsgroups: comp.lang.c++
  2. Path: in2.uu.net!bcstec!plato!hakuin!scott
  3. From: scott@hakuin.boeing.com (Scott Moody, 773-8600)
  4. Subject: Templates passing known classes?
  5. Message-ID: <Do9uKp.MM9@plato.ds.boeing.com>
  6. Sender: news@plato.ds.boeing.com
  7. Nntp-Posting-Host: hakuin
  8. Reply-To: scott@plato.ds.boeing.com
  9. Organization: Boeing Defense and Space Group
  10. Date: Thu, 14 Mar 1996 19:10:00 GMT
  11.  
  12.  
  13. I have a question about the Templates of C++.
  14. What I want to do is pass a class as a template parameter,
  15. but I want the class to be based on some type. I would then
  16. like to use methods from that type in the implementation of the class.
  17.  
  18. eg.
  19.  
  20.   template <class polygons T>
  21.   class stacks
  22. {
  23.    T obj;
  24.   ..  then do things with obj like  obj->circumference()
  25.  
  26. }
  27.  
  28. I should then be only able to instant stacks with something derrived from
  29. the polygons class (eg. squares, triangles). Not something like 'animals'.
  30. ---
  31.  
  32. Second question:
  33.   I want to inherit from multiple classes, but want the user to specify
  34. the classes as a parameter (really just like the template).
  35.  
  36. eg.
  37.  
  38.   class stacks : <class polygons T>
  39. {
  40. }
  41.  
  42. ----
  43. It seems these are important for 'adaptibility' of our programs.
  44.  
  45. Thanks.
  46.  
  47. scott moody
  48.